<!DOCTYPE html>
<html>

<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="穷在闹市"/>
    <!-- 作者 -->
    <meta name="revised" content="穷在闹市.v3, 2019/05/01"/>
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介"/>
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开"/>
    <title>穷在闹市出品</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="../css/base.css">
    <link rel="stylesheet" type="text/css" href="../fonts/iconfont.css">
    <script type="text/javascript" src="../framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../layui/css/layui.css">
    <script type="text/javascript" src="../layui/layui.js"></script>

  
     <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
	 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <script src="../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

    <style>
        .layui-table img {
            max-width: none;
        }
    </style>

</head>

<body>
<div class="cBody">
    <div class="console">
        <form class="layui-form" action="TypeServiet?action=queryBName" method="post">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input type="text" name="name" required lay-verify="required" placeholder="输入商品名称"
                           autocomplete="off" class="layui-input">
                           
                </div>
                <button class="layui-btn" lay-submit lay-filter="submitBut">检索</button>
            </div>

<%--            <input type="hidden" id="count" value="${page.count}">--%>
           <div>

               班级 <select id="mid">
               <option>请选择</option>
               <c:forEach var="classses" items="${classses}">
               <option value="${classses.cid }" style="width: 20px; height: 20px">${classses.claname}</option>
               </c:forEach>
               </select>
                   <form id="addForm" action="PostsServlet?action=add" method="post">
                      课程<select id="sid" name="sid">
                   </select>
                   </form>
           </div>
        </form>
        <script type="text/javascript">
            $(function() {
                $("#mid").change(
                    function() {
                        var mid = $("#mid").val();

                        $.ajax({
                            url : "/subject/querybyclassid",
                            type : "POST",
                            data : {
                                id : mid
                            },
                            success : function(result) {
                                var json = JSON.parse(result);
                                console.log(json);
                                var html = "";
                                for (var i = 0; i < json.length; i++) {
                                    html += "<option value='"+json[i].id+"'>"
                                        + json[i].name + "</option>"
                                }

                                $("#sid").html(html);
                                layui.form.render("select");
                            }
                        });
                    })

            })
        </script>

        <script>
            layui.use('form', function () {
                var form = layui.form;

                //监听提交
                form.on('submit(submitBut)', function (data) {
                    layer.msg(JSON.stringify(data.field));
                    return true;
                });
            });
            
            layui.use('form', function () {
                var form = layui.form;

                //监听提交
                form.on('submit(submitBut)', function (data) {
                    layer.msg(JSON.stringify(data.field));
                    return false;
                });
                
                
            });
        </script>
    </div>

    <table class="layui-table">
        <thead>
        <tr>
        	<th>ID</th>
            <th>题目</th>
            <th>正确答案</th>
            <th>A</th>
            <th>B</th>
            <th>C</th>
            <th>D</th>
            <th>课程名</th>
            <th>操作</th>
        </tr>
        </thead>
        
        <tbody id="tbody">
        <c:forEach var="subject" items="${subject}">
        <tr>
            <td>${subject.id}</td>
            <td>${subject.content}</td>
            <td>${subject.rights}</td>
            <td>${subject.arg1}</td>
            <td>${subject.arg2}</td>
            <td>${subject.arg3}</td>
            <td>${subject.arg4}</td>
            <td>${subject.course.sname}</td>
            <td>
<%--                --%>
                <a class="layui-btn layui-btn-xs" href="/subject/querybyid?&id=${subject.id}">修改</a>
                <a class="layui-btn layui-btn-xs" href="/subject/delete?&id=${subject.id}">删除</a>
            </td>
        </tr>
      </c:forEach>
        </tbody>
    </table>
<%----%>
    <div align="center">
        <%@include  file="/subject/page.jsp"%>
    </div>
</div>
</body>

</html>